package likou;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/08/20 15:49
 */
public class _541 {
    public static void main(String[] args) {
        System.out.println(reverseStr("abcdefg",
                2));
    }
    public static String reverseStr(String s, int k) {
        StringBuilder sb = new StringBuilder("");
        int right = k;
        int left =0;
        while(right<=s.length()){
            sb.append(new StringBuilder(s.substring(left,right)).reverse());
            left+=k;
            right+=k;
        }
        if(right!=s.length()+k){
            sb.append(new StringBuilder(s.substring(left,s.length())).reverse());
        }
        return sb.toString();
    }
}
